package cloudspace.vm.javassist;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * The Class Logger. This is the default logger for the javassist configuration
 * framework. You can register different types of loggers to have log output
 * pushed to.
 */
public class Logger
{
	/** The registered loggers. */
	private static List<TextLogger> registeredLoggers = new ArrayList<TextLogger>();

	/**
	 * Register a log into the logger. Everytime info is logged, each of the
	 * registered loggers are printed to.
	 * 
	 * @param log
	 *            the log to be added to the list of loggers.
	 */
	public static void registerLogger(String fileName)
	{
		registeredLoggers.add(new TextLogger(fileName));
	}

	/**
	 * Log info to the logger. All of the registered loggers will be updated.
	 * 
	 * @param str
	 *            the string to be logged to registered loggers.
	 */
	public static void logInfo(String str)
	{
		Iterator<TextLogger> logIter = registeredLoggers.iterator();
		while (logIter.hasNext())
		{
			TextLogger tempLog = logIter.next();
			tempLog.log(str);
		}
	}

}
